package 二叉树;
public class Solution6 {
    //https://www.nowcoder.com/practice/947f6eb80d944a84850b0538bf0ec3a5
    TreeNode prev = null;
    public TreeNode Convert(TreeNode pRootOfTree) {

     if (pRootOfTree == null) {
         return null;
     }
     Convert(pRootOfTree.left);

     //中序返回时的操作
     pRootOfTree.left = prev;
     if (prev != null) {
         prev.right = pRootOfTree;
     }
     prev = pRootOfTree;

     Convert(pRootOfTree.right);

     TreeNode cur = pRootOfTree;
     while (cur.left != null) {
         cur = cur.left;
     }
     return cur;
    }
}
